Skip to content

More informative Debug for vec::ExtractIf#154581

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
GrigorenkoPV:extract-if-debug
Apr 4, 2026
Merged

More informative Debug for vec::ExtractIf#154581
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
GrigorenkoPV:extract-if-debug

Conversation

@GrigorenkoPV
Copy link
Copy Markdown
Contributor

@GrigorenkoPV GrigorenkoPV commented Mar 30, 2026

While working on #154318, I've realized that vec::ExtractIf actually maintains a valid prefix and a valid suffix in the underlying vector at all times with all the temporarily-invalid elements being only in the middle.

So why not make the Debug output more informative? I guess we could even expose something like get_retained_mut(&mut self) -> &mut [T] and get_remainder_mut(&mut self) -> &mut [T], but that would add new backwards compatibility burden, unlike the Debug implementation, which (IIRC) can be changed at any time.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 30, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 30, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 7 candidates

@Mark-Simulacrum
Copy link
Copy Markdown
Member

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 4, 2026

📌 Commit 6c46776 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 4, 2026
rust-bors bot pushed a commit that referenced this pull request Apr 4, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #149868 (rustc: Stop passing `--allow-undefined` on wasm targets)
 - #153555 (Clarified docs in std::sync::RwLock + added test to ensure that max reader count is respected)
 - #152851 (Fix SGX delayed host lookup via ToSocketAddr)
 - #154051 (use libm for acosh and asinh)
 - #154581 (More informative `Debug for vec::ExtractIf`)
 - #154461 (Edit the docs new_in() and with_capacity_in())
 - #154526 (Panic/return false on overflow in no_threads read/try_read impl)
 - #154798 (rustdoc-search: match path components on words)
@rust-bors rust-bors bot merged commit ab3532f into rust-lang:main Apr 4, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Apr 4, 2026
rust-timer added a commit that referenced this pull request Apr 4, 2026
Rollup merge of #154581 - GrigorenkoPV:extract-if-debug, r=Mark-Simulacrum

More informative `Debug for vec::ExtractIf`

While working on #154318, I've realized that `vec::ExtractIf` actually maintains a valid prefix and a valid suffix in the underlying vector at all times with all the temporarily-invalid elements being only in the middle.

So why not make the `Debug` output more informative? I guess we could even expose something like `get_retained_mut(&mut self) -> &mut [T]` and `get_remainder_mut(&mut self) -> &mut [T]`, but that would add new backwards compatibility burden, unlike the `Debug` implementation, which (IIRC) can be changed at any time.
@GrigorenkoPV GrigorenkoPV deleted the extract-if-debug branch April 4, 2026 21:29
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Apr 5, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#149868 (rustc: Stop passing `--allow-undefined` on wasm targets)
 - rust-lang/rust#153555 (Clarified docs in std::sync::RwLock + added test to ensure that max reader count is respected)
 - rust-lang/rust#152851 (Fix SGX delayed host lookup via ToSocketAddr)
 - rust-lang/rust#154051 (use libm for acosh and asinh)
 - rust-lang/rust#154581 (More informative `Debug for vec::ExtractIf`)
 - rust-lang/rust#154461 (Edit the docs new_in() and with_capacity_in())
 - rust-lang/rust#154526 (Panic/return false on overflow in no_threads read/try_read impl)
 - rust-lang/rust#154798 (rustdoc-search: match path components on words)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants